﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace GermoMarsil
{
    class Germi
    {
        //Germi tekstuur
        Texture2D gerTexture;
        // germi alg positsioon
        Vector2 gerPosition;
        //Germi tekstuuri ümbritsev kast
        Rectangle gerRectangle;
        int speed = 3;

        //Klassi konstruktor.
        // Kõik konstruktiori muutujad kirjutame new + algmuutuja nimi
        public Germi(Texture2D newGerTexture, Vector2 newGerPosition)
        {
            this.gerTexture = newGerTexture;
            this.gerPosition = newGerPosition;
           
        }

        // Joonistame Germi välja 
        public void Draw(SpriteBatch spritebatch)
        {
            // Joonistan germi 3 andme põhjal : Tema textuur ( välimus ), tema algpositsioon, ja tausta värv ( Valge = transparent)
            spritebatch.Draw(gerTexture, gerPosition, Color.White);
        }
        public void Update()
        {
        }
        public void Move()
        {
            gerRectangle = new Rectangle((int)gerPosition.X, (int)gerPosition.Y, gerTexture.Width, gerTexture.Height);
            if (gerPosition.X <= 0)
                gerPosition.X = 0;
            if (gerPosition.Y <= 0)
                gerPosition.Y = 0;
            if (gerPosition.Y + gerTexture.Height + 80 >= Game1.screenHeight)
                gerPosition.Y = Game1.screenHeight - gerTexture.Height - 80;
            if (gerPosition.X + gerTexture.Width + 100 >= Game1.screenWidth)
                gerPosition.X = Game1.screenWidth - gerTexture.Width - 100;

            if (Game1.presentKey.IsKeyDown(Keys.Up))
                gerPosition.Y -= speed;

            if (Game1.presentKey.IsKeyDown(Keys.Down))
                gerPosition.Y += speed;

            if (Game1.presentKey.IsKeyDown(Keys.Left))
                gerPosition.X -= speed;

            if (Game1.presentKey.IsKeyDown(Keys.Right))
                gerPosition.X += speed;
        }
    }
}
